<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ page import="java.sql.*" %>
<%
String id=request.getParameter("id");

Class.forName("com.mysql.jdbc.Driver");
Connection conn=null;
Statement st=null;
ResultSet rs=null;
String url="jdbc:mysql://localhost:3306/2012jb?useUnicode=true&characterEncoding=UTF-8";
String userName="root";
String password="123456";
	conn=DriverManager.getConnection(url,userName,password);
	//3. statement  or preparestatement
	st=conn.createStatement();
	//4.execute sql ResultSet
//SELECT ID,LOGIN_NAME,PASSWORD FROM USER WHERE ID='1'	
	rs=st.executeQuery("SELECT ID,LOGIN_NAME,PASSWORD FROM USER WHERE ID='"+id+"'");
	//5. data handle
	

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		if(rs.next()){
	%>
	<form method="post" action="update.jsp">
		<input type="hidden" name="id" value="<%=rs.getString("ID") %>">
		LoginName<input type="text" name="loginName" 
		value="<%=rs.getString("LOGIN_NAME") %>"><br/>
		Password<input type="text" name="password" 
		value="<%=rs.getString("PASSWORD") %>"><br/>
		<input type="submit" value="Update User">
	</form>
	<%}else{%>
		<h3 style="color:red">出错了，没有找到ID=<%=id %>的记录</h3>
	<%} %>
	<%
		 if(rs!=null)rs.close();
		 if(st!=null)st.close();
		 if(conn!=null)conn.close();
		%>
</body>
</html>